package cn.ld.module.infra.dal.mapper.demo.demo02;

import java.util.*;

import cn.ld.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ld.framework.mybatis.core.mapper.BaseMapperX;
import cn.ld.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListInVO;
import cn.ld.module.infra.dal.entity.demo.demo02.Demo02CategoryEntity;
import org.apache.ibatis.annotations.Mapper;

/**
 * 示例分类 Mapper
 *
 * @author 蓝盾
 */
@Mapper
public interface Demo02CategoryMapper extends BaseMapperX<Demo02CategoryEntity> {

    default List<Demo02CategoryEntity> selectList(Demo02CategoryListInVO inVO) {
        return selectList(new LambdaQueryWrapperX<Demo02CategoryEntity>()
                .likeIfPresent(Demo02CategoryEntity::getName, inVO.getName())
                .eqIfPresent(Demo02CategoryEntity::getParentId, inVO.getParentId())
                .betweenIfPresent(Demo02CategoryEntity::getCreateTime, inVO.getCreateTime())
                .orderByDesc(Demo02CategoryEntity::getId));
    }

	default Demo02CategoryEntity selectByParentIdAndName(Long parentId, String name) {
	    return selectOne(Demo02CategoryEntity::getParentId, parentId, Demo02CategoryEntity::getName, name);
	}

    default Long selectCountByParentId(Long parentId) {
        return selectCount(Demo02CategoryEntity::getParentId, parentId);
    }

}